<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增岗位管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-post-add">
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">岗位编码：</label>
                <div class="col-sm-8">
                    <input name="postCode" class="form-control" type="text" value="post">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">岗位名称：</label>
                <div class="col-sm-8">
                    <input name="postName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">招聘人数：</label>
                <div class="col-sm-8">
                    <input name="needNum" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label is-required">招聘人数：</label>
                <div class="col-sm-8">
                    <input name="actuals" class="form-control" type="text" th:value="0">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">工资：</label>
                <div class="col-sm-8">
                    <input name="salary" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">工作介绍：</label>
                <div class="col-sm-8">
                    <textarea name="mainwork" class="form-control" type="text" rows="5"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">工作地址：</label>
                <div class="col-sm-8">
                    <input name="workplace" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">招聘开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">招聘结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">联系电话：</label>
                <div class="col-sm-8">
                    <input name="phone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "wstudy/post"
        $("#form-post-add").validate({
            focusCleanup: true,
            onkeyup:false,
            rules:{
                postName:{
                    required:true
                },
                needNum:{
                    required:true,
                    number:true
                },
                salary:{
                    required:true,
                    number:true
                },
                mainwork:{
                    required:true,
                    minlength:10
                },
                phone:{
                    required:true,
                    number: true,
                    maxlength:11
                },
            },
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-post-add').serialize());
            }
        }

        $("input[name='startTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>